/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package finger;

import com.griaule.fingerprintsdk.appletsample.Util;
import com.griaule.grfingerjava.Template;
import java.io.ByteArrayInputStream;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JApplet;
import javax.swing.JOptionPane;

/**
 *
 * @author daniel
 */
public class FingerPrint extends JApplet {

    private static Util fingerprintSDKSample;
    private static String matricula;
    private static String fingerPosicao;

    @Override
    public void init(){
        System.out.println("start");
        fingerprintSDKSample = new Util(this);
    }

    @Override
    public void destroy(){
        System.out.println("stop");
        fingerprintSDKSample.destroy();
    }

    public static void setMatricula(String matricula){
        FingerPrint.matricula = matricula;
        System.out.println("Matricula setada: "+FingerPrint.matricula);
    }

    public static String getMensagem(){
        String mensagem = null;
        if(fingerprintSDKSample.getMensagem()!=null){
            mensagem = fingerprintSDKSample.getMensagem();
            fingerprintSDKSample.setMensagem(null);
        }
        return mensagem;
    }

    public static String getFingerPosicao(){
        return FingerPrint.fingerPosicao;
    }

    public static void saveFingerLeft(){
        FingerPrint.fingerPosicao = "Esquerdo";
        fingerprintSDKSample.setMatricula(matricula);
        fingerprintSDKSample.setFingerPos(FingerPrint.fingerPosicao);
        fingerprintSDKSample.setAutoEnroll(true);
        System.out.println("autoEnroll digital esquerda true");
    }

    public static void saveFingerRight(){
        FingerPrint.fingerPosicao = "Direito";
        fingerprintSDKSample.setMatricula(matricula);
        fingerprintSDKSample.setFingerPos(FingerPrint.fingerPosicao);
        fingerprintSDKSample.setAutoEnroll(true);
        System.out.println("autoEnroll digital direita true");
    }

    public static void resetFinger(){
        FingerPrint.fingerPosicao = null;
        fingerprintSDKSample.resetTemplate();
        fingerprintSDKSample.setAutoEnroll(false);
        fingerprintSDKSample.setAutoIdentify(false);
        System.out.println("resetFinger");
    }

    public static void identifyFinger(){
        fingerprintSDKSample.setMatricula(matricula);
        fingerprintSDKSample.setAutoIdentify(true);
    }

}
